<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
        #l-map{height:100%;width:78%;float:left;border-right:2px solid #bcbcbc;}
        #r-result{height:100%;width:20%;float:left;}
    </style>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=KLtyCwukOuzGKKjPzvezlbGv"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/CurveLine/1.5/src/CurveLine.min.js"></script>
    <title>添加多个标注点</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    var point = new BMap.Point(116.404, 39.915);
    map.centerAndZoom(point, 22);
    // 编写自定义函数,创建标注
    function addMarker(point){
        console.log(point);
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
    }

    function addCurve(points) {
        var curve = new BMapLib.CurveLine(points, {strokeColor:"blue", strokeWeight:3, strokeOpacity:0.5}); //创建弧线对象
        map.addOverlay(curve); //添加到地图中
        curve.enableEditing(); //开启编辑功能
    }
    var points = [];
//    var beijingPosition=new BMap.Point(116.432045,39.910683),
//            hangzhouPosition=new BMap.Point(120.129721,30.314429),
//            taiwanPosition=new BMap.Point(121.491121,25.127053);
//    var points = [beijingPosition,hangzhouPosition, taiwanPosition];



    $(document).ready(function() {
        $.ajax({
            type: "GET",
            url: "__MODULE__/Location/page?iId={$iId}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                var dataD = data.data;
                $.each(dataD, function(i) {
                    var point = new BMap.Point(dataD[i].lontitude, dataD[i].latitude);
                    if (i == 0) {
                        map.centerAndZoom(point, 15);
                    }
//                    addMarker(point);

                    points.push(point);
                })
                console.log(points);
                addCurve(points);
            },
            error: function (msg) {
                console.log(msg);
            }
        });
    })

</script>
